package com.yifeng.repo.endpoint.security.auth;

import java.util.ServiceLoader;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * Created by daibing on 2023/8/24.
 */
public class SecurityCheckerFactory {
    private static final ConcurrentMap<String, SecurityChecker> IMPL_MAP = new ConcurrentHashMap<>();

    static {
        ServiceLoader<SecurityChecker> serviceLoader = ServiceLoader.load(SecurityChecker.class);
        for (SecurityChecker securityChecker : serviceLoader) {
            IMPL_MAP.put(securityChecker.consoleType(), securityChecker);
        }
    }

    public static SecurityChecker get(String type) {
        return IMPL_MAP.get(type);
    }
}
